<!DOCTYPE html>
<html lang="en">
	<head>
		<title> New Document </title>
		<meta charset="utf-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- Bootstrap -->
		<link href="${webRoot}resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
		<link href="${webRoot}resources/css/style.css" rel="stylesheet">
		<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
		<style type="text/css">
		.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.80;
		filter: alpha(opacity=80);
		}
		.white_content {
		display: none;
		position: absolute;
		top: 10%;
		left: 10%;
		width: 80%;
		height: 80%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
		.white_content_small {
		display: none;
		position: absolute;
		top: 20%;
		left: 30%;
		width: 40%;
		height: 50%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
	</style>
	</head>
<body class="main">
	<div class="wrap">
		<div class="">
		<ul class="breadcrumb">
		    <li><span id="test">您当前的位置：</span></li>
		    <li class="active">${getShops}</li>
	    </ul>
			<form class="form-inline">
				<input type="text" class="input-small" id="goodsName" placeholder="商家名称">
				<button type="button" class="btn" onclick="serachHref();">搜索</button>
				<button type="button" class="btn" onclick="setNull();">重置</button>
			</form>
		</div>
		<div id ="div">
		<div class="">
			<table class="table table-bordered table-striped table-hover">
				<thead>
					<tr>
						<th>商家名称</th>
						<th>联系电话</th>
						<th>商家地址</th>
						<th>经度</th>
						<th>纬度</th>
						<th>商家等级</th>
						<th>添加时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#if shops?exists>
				<#list shops as shopEntity>
					<tr>
						<td>${shopEntity.name}</td>
						<td>${shopEntity.telephone}</td>
						<td>${shopEntity.address}</td>
						<td>${shopEntity.lon}</td>
						<td>${shopEntity.lat}</td>
						<td>${shopEntity.devel}</td>
						<td>${shopEntity.time?string("yyyy-MM-dd HH:mm:ss")}</td>
						<td>
						<a href="javascript:selectOne(${shopEntity.id});">查看详情</a>
						<a href="javascript:updateGoodsInfo(${shopEntity.id})">修改</a>
						<a href="javascript:selectAdvers(${shopEntity.id})">查看招聘信息</a>
						<a href="javascript:addAdver(${shopEntity.id})">添加招聘信息</a>
						<a href="javascript:deleteGoods(${shopEntity.id});">删除</a>
						</td>
					</tr>
				</#list>
				<#else>
				   	 <tr>
				       <td colspan="9">没有查询到记录！</td>
				   </tr>
				</#if>
				</tbody>
			</table>			
		</div>
		<#if shops?exists>
		<div class="pagination pagination-right">
		  <ul>
		    <#if pageEntity.page==1>
		    <li class="disabled"><a href="#">&laquo;</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page-1},${pageEntity.totalPage},${pageEntity.pageSize})">&laquo;</a></li>
		    </#if>
		    <#list 1..pageEntity.totalPage as i>
		         <#if pageEntity.page==i>
		    <li class="active"><a href="#">${i}</a></li>
		         <#else>
		    <li><a href="javascript:pageHref(${i},${pageEntity.totalPage},${pageEntity.pageSize})">${i}</a></li>
		        </#if>
		    </#list>
		   <#if pageEntity.page==pageEntity.totalPage>
		    <li class="disabled"><a href="#">»</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page+1},${pageEntity.totalPage},${pageEntity.pageSize})">»</a></li>
		    </#if>
		  </ul>
		</div>
		</#if>
		</div>			
	</div>
	<!--弹出层时背景层DIV-->
<div id="fade" class="black_overlay">
</div>
<div id="MyDiv" class="white_content">
</div>	
	<script src="${webRoot}resources/js/bootstrap.min.js"></script>
	<script src="${webRoot}resources/js/js.js"></script>
	<script type="text/javascript">
	    function pageHref(page,totalPage,pageSize){
	    	var goodsName = escape(escape($("#goodsName").val()));
	    	$.ajax({url:"${webRoot}shop/shopAjaxList.do?page="+page+"&pageSize="+pageSize+
	    			"&totalPage="+totalPage+"&name="+goodsName,
				   type:"post",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
	    }
	    function serachHref(){
	    	var goodsName = escape(escape($("#goodsName").val()));
	    	$.ajax({url:"${webRoot}shop/shopAjaxList.do?name="+goodsName,
				   type:"post",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
	    }
	function deleteGoods(id){
		if(confirm("删除该商家，他下面的商品也会删除，确定删除吗？")){
	    	$.ajax({url:"${webRoot}shop/deleteShop.do?id="+id,
				   type:"delete",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
			}
	}
	
	function updateGoods(id,status){
		$("#goodsStatus").val("");
    	$.ajax({url:"${webRoot}goods/updateGoodsStatus.do?goods_id="+id+
			"&goods_Statu="+status,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#goodsStatus").val("");
				   $("#div").html(msg);
			   }
			});
	}
	
	function selectOne(id){
		$.ajax({url:"${webRoot}shop/selectOneShop.do?id="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	
	function selectAdvers(id){
		$.ajax({url:"${webRoot}shop/getAdversByShopId.do?shop_id="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	
	function pageHrefAdver(page,totalPage,pageSize){
		var shopId = $("#shopId").val();
    	$.ajax({url:"${webRoot}shop/getAdversByShopId.do?page="+page+"&pageSize="+pageSize+
    			"&totalPage="+totalPage+"&shop_id="+shopId,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
    }
	function deleteAdver(id,shopId){
			if(confirm("确定删除该招聘信息吗？")){
		    	$.ajax({url:"${webRoot}shop/deleteAdver.do?id="+id+
		    			"&shop_id="+shopId,
					   type:"delete",
					   cache:"false",
					   error : function() {
						   alert("系统繁忙，请稍后再试！");
						},
					   success:function(msg){
						   $("#MyDiv").html(msg);
						   ShowDiv('MyDiv','fade');
					   }
					});
				}
	}
	
	function updateGoodsInfo(id){
		window.location.href="${webRoot}shop/updateShopInfo.do?id="+id
	}
	function addAdver(id){
		window.location.href="${webRoot}shop/addAdver.do?id="+id
	}
	function setNull(){
		$("#goodsName").val("");
		$("#goodsStatus").val("");
	}
	
	function insertComment(id,name){
		$("#goods_Id").val(id);
		$("#goods_name").val(name);
		document.getElementById("insertComment").submit();
	}
	
	function insertPice(id,name){
		$("#goods_id").val(id);
		$("#goods_name").val(name);
		document.getElementById("insertPic").submit();
	}
	
	function sendGoods(id,name){
		$("#goodsId").val(id);
		$("#goods_Name").val(name);
		document.getElementById("sendGoods").submit();
	}
	function selectPic(id){
		$.ajax({url:"${webRoot}pic/getListPice.do?goods_id="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	function pagePic(page,totalPage,pageSize){
		var picgoodsId = $("#picgoodsId").val();
    	$.ajax({url:"${webRoot}pic/getListPice.do?page="+page+"&pageSize="+pageSize+
    			"&totalPage="+totalPage+"&goods_id="+picgoodsId,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
    }
	
	function deletePic(picId,goodsId){
		if(confirm("确定删除该图片吗？")){
	    	$.ajax({url:"${webRoot}pic/deletePic.do?pic_id="+picId+
	    			"&goods_id="+goodsId,
				   type:"delete",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#MyDiv").html(msg);
					   ShowDiv('MyDiv','fade');
				   }
				});
			}
}
	//弹出隐藏层
	function ShowDiv(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;
	// bgdiv.style.height = $(document).height();
	$("#"+bg_div).height($(document).height());
	};
	//关闭弹出层
	function CloseDiv(show_div,bg_div)
	{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
	};
	</script>
</body>
</html>
